//
//  XHAuthorizeController.m
//  围脖
//
//  Created by 魏兴浩 on 15/12/15.
//  Copyright © 2015年 wxh. All rights reserved.
//

#import "XHAuthorizeController.h"
#import "XHNetworkTool.h"
@interface XHAuthorizeController ()
@property (nonatomic,strong)UIWebView *webView;
@property (nonatomic,strong)XHNetworkTool *nTool;
@end

@implementation XHAuthorizeController
-(void)loadView{
    //网络工具
    self.nTool = [XHNetworkTool sharedManager];
    NSLog(@"授权网络工具的nTool地址：%@",self.nTool);
    self.view = self.webView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //授权登录
    [self loginAuthorze];
    //导航栏按钮
    [self setNavigationItem];

}
#pragma mark -用户授权登录
-(void)loginAuthorze{
    //授权地址
    NSURLRequest *request = [NSURLRequest requestWithURL:self.nTool.loginAuthorizeUrl];
    //使用当前webView显示授权地址
    [self.webView loadRequest:request];

}
#pragma maek -设置导航栏按钮
-(void)setNavigationItem{
    //左边按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(leftBtnClick)];
    
}
-(void)leftBtnClick{
    NSLog(@"点击取消");
    //关闭授权控制器
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark -懒加载
-(UIWebView *)webView{
    if (!_webView) {
        _webView = [[UIWebView alloc]init];
    }
    return _webView;
}

@end
